﻿#region Using

using System;
using System.Xml.Serialization;

using Common.Enums;

using Menu.Components;

#endregion

namespace Menu.XmlEntities
{
    [Serializable]
    public class XmlText : XmlBaseEntity
    {
        public XmlText()
        {
            this.Stackable = true;
        }

        [XmlAttribute("Value")]
        public string Value { get; set; }

        [XmlAttribute("Size")]
        public FontSizeEnum FontSize { get; set; }

        [XmlAttribute("Font")]
        public FontEnum FontEnum { get; set; }

        [XmlAttribute("LineHeight")]
        public int LineHeight { get; set; }

        [XmlElement("Stack")]
        public bool Stackable { get; set; }

        [XmlAttribute("HorizontalAlignment")]
        public HorizontalAlignment HorizontalAlignment { get; set; }

        [XmlAttribute("VerticalAlignment")]
        public VerticalAlignment VerticalAlignment { get; set; }

        [XmlElement("ToolTip")]
        public XmlToolTip ToolTip { get; set; }
        
        internal override MenuComponentBase GetComponent(MenuComponentBase parent)
        {
            var comp = new Text(this.Id, base.GetComponent(parent), this.FontEnum, this.FontSize);
            comp.Stackable = this.Stackable;
            comp.Value = this.Value;
            comp.LineHeight = this.LineHeight;
            comp.HorizontalAlignment = this.HorizontalAlignment;
            comp.VerticalAlignment = this.VerticalAlignment;
            comp.Command = this.Command;

            if (this.ToolTip != null)
            {
                comp.ToolTip = this.ToolTip.GetComponent();
            }

            comp.Settle();

            return comp;
        }
    }
}